﻿@model FShare.ViewModels.DisplayViewModel

@{
    ViewBag.Title = "FShare - download links";
}

<h2>Download Links</h2>

<p>For security of your files, please don't share this link with no one.</p>

<div>
    <div id="file-area">
    <span class="file-control-area"><a href="#" id="show-delete-links">Show delete links</a></span>
    @foreach (var file in Model.Files)
    {
        <div class="file-general-info">
            <span>File name: <span class="file-info">@file.Name</span></span>
            <span>Size: <span class="file-info">@(file.Size / 1024) KB.</span></span>
            <span>Downloaded: <span class="file-info">@file.NumberOfDownloads</span> times.</span>
        </div>
        <div class="file-links">
        @{
            string downloadUrl = new Uri(Request.Url.GetLeftPart(UriPartial.Authority) + "/Files/Download/" + file.DownloadSecret).ToString();
            <div class="file-box">
                <span>Download link:</span>
                <input type="text" class="file-link-box download-link" value="@downloadUrl" />
            </div>
            <div class="file-box delete-link-area">
            @{
                <span>Delete link:</span>
                string deleteUrl = new Uri(Request.Url.GetLeftPart(UriPartial.Authority) + "/Files/Delete/" + file.DeleteSecret).ToString();
                <input type="text" class="file-link-box delete-link" value="@deleteUrl" />
            }
            </div>
        }
        </div>
    }
    </div>
    <script type="text/javascript">
        $(".file-link-box").focus(function () {
            this.select();
        });
        var shown = false;
        var show_link = $("#show-delete-links");
        $(".delete-link-area").hide();
        show_link.click(function () {
            var speed = 500;
            $(".delete-link-area").slideToggle(speed);
            shown = !shown;
            show_link.text(shown ? "Hide delete links" : "Show delete links");
        });
    </script>
</div>